import React, { Component } from 'react';
import { Text, View, ScrollView, KeyboardAvoidingView, Platform, Image, TouchableOpacity, DeviceEventEmitter, Alert } from "react-native";
import { orderBaseStyle } from './_common/style.js'
import { Common } from '../../../component/common/Common.js'
import { FormItem } from '../../../components/form/formItem'
import { Button } from '../../../components/form/button'
import { PageStatusIndex } from '../../../component/page-status/PageStatusIndex';
import OrderAPIService from './_common/OrderAPIService'
import OrderCreactService from './_common/service'
import ToastUtil from '../../../utils/toast';
import Utils from '../../../utils/utils';
import MethodUtil from '../../../utils/MethodUtil';
import { STORAGE_CONSTANT } from '../../../config/storage';
import StorageHelper from '../../../utils/storageHelper';

import { TitleCpt } from './_components/TitleCpt'
import { RadiusGroupCpt } from './_components/RadiusGroupCpt'
import { AddressCpt } from './_components/AddressCpt'
import { DeliveryBlock } from './_block/DeliveryBlock'
import { FeeBlock } from './_block/FeeBlock'
import { GoodsBlock } from './_block/GoodsBlock'
import { RemarkBlock } from './_block/RemarkBlock'
import { GET_R_TITLE_NAME } from '../../../config/definition'
import { PayCBlock } from './_block/PayCBlock'
import { AdressCBlock } from './_block/AdressCBlock'

import Dictionary from '../../../utils/dictionary';
import { CURRENCY } from '../../../utils/helper';

import { style } from '../../../theme/style';
import { GLOBAL } from '../../../config/global';

import HTTP from '../../../utils/http';
import { API, API_GENERATE } from '../../../config/api';
import moment from 'moment';

import { BottomCpt } from '../_components/BottomCpt';
import { BouncedCpt } from '../_components/BouncedCpt';
import { BodyCpt } from '../_components/BodyCpt';
import OrderCreateMethods from '../OrderCreateMethods';
import ConstData from '../../../utils/constData';
import { DatePicker } from 'react-native-pickers';

const scale = GLOBAL.SCALE;
const currentMonth = moment().format('YYYYMM');
const nextMonth = moment().add('months', 1).format('YYYYMM');
/*
*orderType  销售->S   采购->P
*tCode   现货->S   长约->L  远期->F   代理->A   E->长约执行  C->背靠背  QH ->泉化


*periodType //长约合同->L   普通合同->S

*oppoOrderId  闭口的第一步采购订单号
*oppoDeliveryType  第二步的 交货方式
*/
/* 多次点击提交问题 */
/*  交易类型现在没有（默认内贸） */

export class orderBasePage extends Component {
    static navigationOptions = ({ navigation, navigationOptions }) => {
        let params = navigation.state.params || {};
        let { tCode, batch } = params;
        return {
            title: params.navTitle || '',
            headerTintColor: "#fff",
            headerLeft: <Common type="headLeft" onPress={() => {
                if (tCode == 'QH' && batch) {
                    navigation.goBack();
                } else {
                    Alert.alert('提示', `离开将清空页面数据?`, [
                        {
                            text: '确认', onPress: () => {
                                this.relevanceOrderList = false;
                                navigation.goBack()
                            }
                        },
                        {
                            text: '取消', onPress: () => { }
                        },
                    ]);
                }
            }} color='#fff' />,
            headerRight: (<Image style={{ marginLeft: 18 * scale, width: 9 * scale, height: 16 * scale }} source={require('../../../imgs/goBackEmpty.png')} />),
            headerStyle: {
                elevation: 0,
                backgroundColor: style.color.themeColor,
            },
            headerTitleStyle: {
                flex: 1,
                textAlign: 'center'
            }
        }
    }
    requesting;
    constructor(props) {
        super(props);
        console.log('页面传递参数', this.props.navigation.state.params)
        this.resetPage = OrderCreactService.reset.bind(this);
        let { tCode, orderType, periodType, orderId, isAgency, bizMode, isFuture, longOrderId, isQhXhXsBiz, batch, longIframe, type } = this.props.navigation.state.params || {};

        // 标识
        this.orderId = orderId || longOrderId || null; // 编辑用
        this.orderFlag = { tCode, orderType, periodType };
        //泉化批量
        this.batch = batch || false;
        //框架(长约/泉化)
        this.longIframe = longIframe || false;

        this.orderFlag.tCode = tCode || this.getTCode(isAgency, bizMode, periodType, isFuture, longOrderId, isQhXhXsBiz);
        tCode = this.orderFlag.tCode;
        this.orderFlag.type = type || null;



        this.state = {
            trustShow: false,//是否显示授信
            lostRateIndex: -1,
            lostRateVisible: false,
            branchIndex: -1,
            branchVisible: false,
            status: 'data',
            user: false, // 交货计划输入控制
            deliveryTypeIsX: false,//长约执行 交货方式为其他(依据子合同)
            isVisible: false  //底部详情弹框
        }
        // 数据字典
        this.businessTypeData = []    // 业务类型 
        this.payTypeData = []//付款类型
        this.payTypeArr = [] //付款类型后面输入部分
        this.payMethodData = []  //付款方式
        this.deliveryData = [];//交货方式
        this.transportTypeData = []; // 运输方式
        this.lossData = [];//运损承担方
        this.lostRateData = [];//途损率
        this.branchData = null;//替哪个部门采

        //默认参数(带初始化)
        this.default = {
            tradeType: 'I',
            isUnite: orderType == 'P' ? '0' : null,// 业务类型 
            currency: 'RMB', // 币种
            //logisticsPrice: '0', // 运费单价默认为0
            lostRender: '2',//运损承担方('默认对方')
            lostRateBig: '3',//途损率默认千分之3
            contractStandard: 1,//	contractStandard,//是否标准合同 0非标  1标准
            bizMode: tCode == 'C' ? '1' : '0',
            companyName: null,
            orderType,
            periodType,
        }

        // 参数
        this.sendData = {
            orderInfo: {
                payType: null,  // 付款类型
                deliveryType: null, // 交货方式
                transportType: null, // 运输方式
                payStyle: null, // 付款方式
                ...this.default
            }
        }

        //参数闭口
        this.sendBuyData = {
            orderInfo: {
                payType: null,  // 付款类型
                deliveryType: null, // 交货方式
                transportType: null, // 运输方式
                payStyle: null, // 付款方式
                ...this.default
            }
        }

        // 授信展示数据
        this.showData = {
            limitAmount: '',
            creditEndDate: '',
            isExpired: null,
            accountDay: 0 // 账期天数
        }

        // 地址用 必填
        this.isVerify = {
            startAddress: null,
            endAddress: null
        }
        //字段标题采购/销售之分
        this.PageText = {};
        //底部价格费用展示
        this.showPrice = {};
        //客户是否白名单
        this.whiteCredit = '0';
    }

    async componentWillMount() {
        let { tCode, orderType } = this.orderFlag;
        await this._userInfo();
        await this._init();

        //设置标题
        this.props.navigation.setParams({
            navTitle: GET_R_TITLE_NAME(orderType, tCode)
        })

        DeviceEventEmitter.addListener('historyFn', (res) => {
            this.isHistory = res.isHistory || false;
        });
        //处理 从关联页面返回 加一个开关 防止清空了 orderId 号
        DeviceEventEmitter.addListener('relevanceOrderList', (res) => {
            this.relevanceOrderList = res.relevanceOrderList || false;
        });
        if (this.orderId || this.batch) { //编辑 批量
            this._editFn(this.orderId);
        }
    }

    // 获取用户基本信息
    _userInfo = async () => {
        let account = null;
        try {
            account = await StorageHelper.get(STORAGE_CONSTANT.USER_INFO_KEY);
        } catch (error) {
            console.log(error);
        }
        this.userInfo = JSON.parse(account) || {};
        console.log('this.userInfo', this.userInfo)
    }


    /*----------------------- 初始化 start-------------------- */
    _init = async () => {
        this._initPageTitle();
        await this._getDictList();
        await this._getConst();
    }

    _getConst = async () => {
        let Const = await ConstData.get();
        console.log('Const', Const);
        if (Const) {
            this.constProportion = Const.ORDER_PRICE_FEE_RATE;
        }
    }

    //字段标题采购/销售之分
    _initPageTitle = () => {
        let { orderType } = this.orderFlag
        if (orderType === 'P') {
            this.PageText.companyTitle = '供应商';
            this.PageText.payTypeTitle = '付款类型';
            this.PageText.payMethodTitle = '付款方式';
        } else {
            this.PageText.companyTitle = '客户';
            this.PageText.payTypeTitle = '收款类型';
            this.PageText.payMethodTitle = '收款方式';
        }
    }

    //过滤子合同
    _filterChild = (filterData) => {
        console.log('filterData', filterData)
        let lsArr = [];
        filterData.forEach((item) => {
            if (item.dictKey != 'X') {
                lsArr.push(item);
            }
        })
        return lsArr;
    }


    //获取数据库字典
    async _getDictList() {
        let { tCode, orderType } = this.orderFlag;
        let deliveryTypeDic = orderType == 'P' ? 'EC_PURCHASE_DELIVERY_TYPE' : 'EC_SALES_DELIVERY_TYPE';

        // 业务类型
        let businessTypeDic = orderType == 'P' ? 'ORDER_PURCHASE_UNITE_FLAG' : 'ORDER_SALE_UNITE_FLAG';
        this.businessTypeData = await Dictionary.get(businessTypeDic);   // 业务类型
        //付款类型
        this.inPayTypeData = await Dictionary.get('EC_PAY_TYPE'); // 付款类型
        this.QHPayTypeData = await Dictionary.get('EC_QH_PAY_TYPE');// 泉化-付款类型
        if (tCode === 'QH') {
            this.payTypeData = this.QHPayTypeData;
        } else {
            this.payTypeData = this.inPayTypeData;
        }
        console.log('this.payTypeData', this.payTypeData)
        //付款方式
        this.payMethodData = await Dictionary.get('EC_PAY_METHOD');
        this.payMethodDataOld = this.payMethodData;
        //交货方式
        this.deliveryDataOld = await Dictionary.get(deliveryTypeDic);
        this.deliveryData = await Dictionary.get(deliveryTypeDic);
        this.deliveryData = this._ruleOutArr(this.deliveryData);
        this.deliveryDataNew = this._ruleOutArr(this.deliveryData);
        if (tCode === 'S') {
            this.deliveryData = this._filterChild(this.deliveryData);
        }
        //交货方式-采
        this.deliveryDataBuy = await Dictionary.get('EC_PURCHASE_DELIVERY_TYPE');
        this.deliveryDataBuy = this._ruleOutArr(this.deliveryDataBuy);
        //交货方式-销
        this.deliveryDataSell = await Dictionary.get('EC_SALES_DELIVERY_TYPE');
        this.deliveryDataSell = this._ruleOutArr(this.deliveryDataSell);

        if (tCode === 'C') {
            this.deliveryDataBuy = this._filterChild(this.deliveryDataBuy);
            this.deliveryDataSell = this._filterChild(this.deliveryDataSell);
        }







        //运损承担方
        this.lossData = await Dictionary.get('EC_OD_LOST_RENDER');
        //运输方式
        this.transportTypeData = await Dictionary.get('EC_TRANSPORT_TYPE');
        this.transportTypeDataOld = this.transportTypeData;
        //途损率
        this.lostRateData = await Dictionary.get('LOST_RENDER_TYPE');
        //特例 途损率 液体商品用
        this.lostRateDataOld = this.lostRateData;

        //替哪个部门采
        if (this._isBranch()) {
            this.branchData = await OrderAPIService.findBranch();
            if (JSON.stringify(this.branchData) != "{}") {
                this.branchData && this.branchData.map((item, index) => {
                    item.dictKey = item.organId;
                    item.dictName = item.organName;
                    return item;
                })
                this.branchData = this.branchData.filter(item => item.organId != this.userInfo.organId); // 过滤本部门
                if (this.branchData.length < 1) {
                    this.branchData = null;
                }
            } else {
                this.branchData = null;
            }
            console.log('this.branchData', this.branchData)
        }

        this.setState({
            ls: true
        })
    }

    //排除依据子合同
    _ruleOutArr = (sendArr) => {
        let newArr = [];
        sendArr && sendArr.forEach(item => {
            if (item.dictKey != "X") {
                newArr.push(item)
            }
        })
        return newArr;
    }

    getTCode = (isAgency, bizMode, periodType, isFuture, longOrderId, isQuanHua) => {
        let tCode = 'S';//现货
        if (isAgency == 1) { tCode = 'A' };//代理
        if (bizMode == 1) { tCode = 'C' };//闭口
        if (periodType == 'L') { tCode = 'L' };//长约框架
        if (isFuture == 1) { tCode = 'F' };//远期
        if (longOrderId) { tCode = 'E' };//执行
        if (isQuanHua === 'Y') { tCode = 'QH' };//泉化销售单
        return tCode;
    }

    /*----------------------- 初始化 end-------------------- */



    /* -----------------------  编辑 start ------------------------ */

    _hisCallback = (orderId) => {
        this._editFn(orderId)
    }

    _editFn = async (orderId) => {
        let { tCode, orderType } = this.orderFlag;
        let url = tCode == 'C' ? API.FIND_ORDER_C : (tCode == 'E' || tCode == 'QH' ? API.FIND_ORDER_E : API.FIND_ORDER)
        let { orderInfo } = this.props.navigation.state.params || {};

        this.setState({ status: 'loading' });
        let getOrderData
        if (this.batch) { // 泉化批量
            getOrderData = orderInfo;
            this.orderId = orderInfo.orderInfo.orderId;
            console.log('泉化批量', getOrderData)
        } else {
            getOrderData = await HTTP.POST(API_GENERATE(url), { orderId });
        }
        this.setState({ status: 'data' });
        console.log('编辑', getOrderData, this.isHistory)
        if (!getOrderData) return;
        if (tCode == 'C') { // 闭口
            this._editBaseFn(getOrderData.purchaseOrder.orderInfo, 'buy');
            this._editBaseFn(getOrderData.saleOrder.orderInfo);
            this._editGoodsFn(getOrderData.purchaseOrder.orderItemList, 'buy');
            this._editGoodsFn(getOrderData.saleOrder.orderItemList);
            this._editPlanFn(getOrderData.purchaseOrder.orderDeliveryPlanList, 'buy');
            this._editPlanFn(getOrderData.saleOrder.orderDeliveryPlanList);
            this._editFee(getOrderData.purchaseOrder.orderFeeList, 'buy');
            this._editFee(getOrderData.saleOrder.orderFeeList);
        } else {
            this._editBaseFn(getOrderData.orderInfo);
            this._editGoodsFn(getOrderData.orderItemList);
            this._editPlanFn(getOrderData.orderDeliveryPlanList);
            this._editFee(getOrderData.orderFeeList);
        }

        //特殊部分
        // 泉化 显示 客户资金
        if (tCode === 'QH') {
            let responseData = await OrderAPIService.getCustomerFunds({ companyId: getOrderData.orderInfo.companyId, currency: this.sendData.orderInfo.currency }) || {};
            this.sendData.orderInfo.funds = responseData.value;
        }

        //长约执行 控制可编辑 不可编辑
        let deliveryTypeIsX = false;
        if ((tCode == 'E' || tCode == 'QH') && getOrderData.orderInfo.deliveryType === 'X') {
            deliveryTypeIsX = true;
            this.sendData.orderInfo.deliveryType = null;
            this.sendData.orderInfo.deliveryTypeName = null;
        }
        if (tCode == 'S' && orderType == 'P' && getOrderData.orderInfo.deliveryType === 'Q') { // 去掉采购的 客户自提选项
            this.sendData.orderInfo.deliveryType = null;
            this.sendData.orderInfo.deliveryTypeName = null;
            this.sendData.orderInfo.logisticsFee = null; // 运费成本
            this.sendData.orderInfo.srcAddressId = null; // 出库地
            this.sendData.orderInfo.srcAddress = null;// 出库地
        }

        //资信评级控制 收款/付款类型
        if (getOrderData.orderInfo && getOrderData.orderInfo.companyCreditLevel) {
            this._filterCredit(getOrderData.orderInfo.companyCreditLevel);
        }
        //编辑,框架用
        this._showPriceFn(this._changeSend())
        this.setState({ ls: true, deliveryTypeIsX: deliveryTypeIsX })
    }

    //基本信息编辑
    _editBaseFn = async (baseData, type) => {
        let { tCode, orderType } = this.orderFlag;
        // 初始默认值
        baseData.tradeType = baseData.tradeType || 'I';
        baseData.currency = baseData.currency || 'RMB';
        baseData.orderInfo = baseData.orderInfo || 'I';
        console.log('base', baseData);

        //收款/付款类型 后面编辑的初始化
        this.payTypeInit(baseData);
        //途损率
        if (baseData.lostRate == null) {
            baseData.lostRate = 0.003;
            baseData.lostRateBig = MethodUtil.countObj.multiply(baseData.lostRate, 1000);// 途损率
        } else {
            baseData.lostRateBig = MethodUtil.countObj.multiply(baseData.lostRate, 1000);// 途损率
        }


        if (type == 'buy') {  // 闭口
            this.sendBuyData.orderInfo = baseData;
            this.creditLevelBuy = baseData.companyCreditLevel; //资信评级
        } else {
            this.sendData.orderInfo = baseData;
            this.creditLevelSell = baseData.companyCreditLevel; //资信评级
        }
        //授信数据展示
        this.initTrust(baseData.payType);

        //长约执行框架
        if (baseData.longOrderId) {
            let responseData = await HTTP.POST(API_GENERATE(API.FIND_ORDER_E), { orderId: baseData.longOrderId });
            if (responseData) {
                this.frameGoodsList = responseData.orderItemList;
                this.iframeid = baseData.longOrderId;  //
                this.setState({ ls: true });
            }
        }

        // 销售+长约 需要业务员自己选择
        if (tCode == 'E' && orderType == 'S') {
            this.sendData.orderInfo.isUnite = null;
        }
        if (this.longIframe) {//如果是框架进来 清空
            this.sendData.orderInfo.auditRemark = null;
        }

        //客户为风控白名单类型过滤
        if (orderType == 'S' && tCode != 'C' && this.sendData.orderInfo.whiteCredit == '1') {
            this.whiteCredit = '1';
        } else {
            this.whiteCredit = '0';
        }

        //清除一下历史数据
        if (tCode == 'S' && this.sendData.orderInfo.whiteCredit == '0' && this.sendData.orderInfo.payType == '6') {
            this.sendData.orderInfo.payType = null;
            this._clearPayTypeData();
        }

    }

    //商品数据编辑
    _editGoodsFn = (goodsData, type) => {
        let { tCode } = this.orderFlag;

        // 计划月份管控
        if (tCode == 'S' || tCode == 'E' || tCode == 'QH') {
            goodsData && goodsData.map(item => {
                item.orderPlanMonth = item.orderPlanMonth == nextMonth ? nextMonth : currentMonth
                return item;
            })
        }

        // 历史下单
        if (this.isHistory) {
            goodsData && goodsData.map(item => {
                if (tCode == 'C') {
                    item.salePrice = null;
                    item.purchasePrice = null;
                }
                item.quantity = '';
                item.price = null;
                item.orderPlanMonth = null;
                item.itemId = null;
                return item;
            })
        }

        // 液化气商品用 壹化网
        if (tCode == 'QH') {
            goodsData && goodsData.map(item => {
                if (item.qhPriceChangeFlag == '1' && item.sourceData == 'CHEMIC') {
                    item.isQhFlag = true;
                } else {
                    item.isQhFlag = false;
                }
                return item;
            })
        }
        //长约
        if (this.longIframe) { 		//长约/泉化 数据回显特殊处理
            if (tCode == 'QH' && !this.batch) {
                // 泉化
                goodsData && goodsData.map(item => {
                    item.quantity = '';
                    item.goodsId = null;
                    item.goodsName = null;
                    item.itemId = null;
                    // 液化气商品用 壹化网
                    if (item.qhPriceChangeFlag == '1' && item.sourceData == 'CHEMIC') {
                        item.isQhFlag = true;
                    } else {
                        item.isQhFlag = false;
                    }
                    return item;
                })
                this.longFrameData = goodsData[0];
                if (this.longFrameData) {
                    this.ysPercent = this.longFrameData.ysPercent;
                }
            } else {
                // 执行
                this.longFrameData = null;
                this.frameGoodsList = goodsData || [];
                // this.ysPercent = null; // 溢短装率 传值
                // if (this.frameGoodsList[0]) {
                //     this.ysPercent = this.frameGoodsList[0].ysPercent;
                // }
            }
            this.ysPercent = null; // 溢短装率 传值
            if (goodsData[0]) {
                this.ysPercent = goodsData[0].ysPercent;
            }
        } else {
            if (type == 'buy') {
                this.sendBuyData.orderItemList = goodsData;
            } else {
                this.sendData.orderItemList = goodsData;
            }
        }
    }

    // 交货计划编辑
    _editPlanFn = (planData, type) => {

        planData = planData && planData.map(item => {
            if (item.quantity) {
                item.quantity = item.quantity + '';
            } else {
                item.quantity = null;
            }
            return item
        })

        console.log('交货计划', this.isHistory)
        if (type == 'buy') {
            if (this.isHistory) { // 历史订单 
                this.sendBuyData.orderDeliveryPlanList = [{ planId: null, deliveryBeginDate: null, deliveryEndDate: null, quantity: null }];
            } else {
                this.sendBuyData.orderDeliveryPlanList = planData;
            }
        } else {
            if (this.isHistory) {// 历史订单
                this.sendData.orderDeliveryPlanList = [{ planId: null, deliveryBeginDate: null, deliveryEndDate: null, quantity: null }];
            } else {
                this.sendData.orderDeliveryPlanList = planData;
            }
        }


    }

    //费用预估编辑
    _editFee = (feeData, type) => {
        if (type == 'buy') {
            this.sendBuyData.orderFeeList = feeData;
        } else {
            this.sendData.orderFeeList = feeData;
        }
    }

    // 付款类型初始化
    payTypeInit = (lsobj) => {
        let dictKey = lsobj.payType;
        let payTypeArr = [];
        this.inPayTypeData.forEach((item, indexKey) => {
            if (item.dictKey == dictKey && item.comments) {
                this.payTypeArr = this.inPayTypeData[indexKey] && this.inPayTypeData[indexKey].comments ? eval(this.inPayTypeData[indexKey].comments) : [];
            }
        })
        this.payTypeArr.forEach((item) => {
            item.value = lsobj[item.name];
        })
        return payTypeArr;
    }

    /* -----------------------  编辑 end ------------------------ */




    /* ---------------------授信有关 start-------------------------- */

    //付款类型-授信初始化
    async initTrust(payType) {
        await this.trustFn();
        this.setState({ trustShow: this.judgeTrust(payType) })
    }
    //授信初始化
    async trustFn() {
        if (!this.sendData.orderInfo.companyId) return
        let trustSend = {
            companyId: this.sendData.orderInfo.companyId,
            corpType: this.orderFlag.orderType == 'P' ? '1' : '2',
            orderType: this.orderFlag.orderType
        }
        let trustData = await OrderAPIService.orderTrust(trustSend);
        console.log('授信初始化', trustData)
        if (trustData) {
            let { limitAmount, creditEndDate, accountDay, isExpired } = trustData;
            this.showData.limitAmount = limitAmount || '';
            this.showData.creditEndDate = creditEndDate || '';
            this.showData.isExpired = isExpired || '0';
            this.showData.accountDay = accountDay || 0;
        }
    }
    //付款类型-是否授信初始化
    judgeTrust = (payType) => {
        let trustShow = false
        let { orderType, tCode } = this.orderFlag;
        //长约执行与长约框架 没有授信
        // if (tCode === 'L' || tCode === 'E') {
        //     return
        // }
		/*采购:保证金/定金  款到发货
			销售:货到付款  票到付款*/
        if (orderType == 'P') {
            if (payType == '2' || payType == '4') {
                trustShow = true;
            }
        } else if (orderType == 'S') {
            if (payType == '3' || payType == '5') {
                trustShow = true;
            }
        }
        return trustShow
    }

    /* ---------------------授信有关 end-------------------------- */



    /* --------------------- 功能函数 start --------------- */
    _providerAddFn = (typeStr, isAgent) => {
        let { orderItemList, orderInfo } = this.sendData || {};
        let { companyId } = orderInfo || {};
        let { tCode, orderType } = this.orderFlag;
        if (tCode == 'QH' || tCode == 'E') {
            Alert.alert('提示', `离开将清空页面数据,确定离开吗?`, [
                {
                    text: '确认', onPress: () => {
                        this._providerFn(typeStr, isAgent);
                    }
                },
                {
                    text: '取消', onPress: () => { }
                },
            ]);
        } else {
            if (tCode == "S" && orderType == "S" && companyId && orderItemList && orderItemList.length) { // 优惠价处理
                Alert.alert('提示', `修改企业将会清空商品信息,确定修改企业吗?`, [
                    {
                        text: '确认', onPress: () => {
                            this.sendData.orderItemList = [];
                            this.setState({ ls: true }, () => {
                                this._providerFn(typeStr, isAgent);
                            })
                        }
                    },
                    {
                        text: '取消', onPress: () => { }
                    },
                ]);
            } else {
                this._providerFn(typeStr, isAgent);
            }

        }

    }



    //选择供应商/客户
    _providerFn = (typeStr, isAgent) => {  // 不完整
        let { tCode, orderType } = this.orderFlag;
        //编辑状态不可修改供应商
		/* if (this.state.pageEdit) {
			return
        } */
        if (tCode == 'C') {
            orderType = typeStr == 'buy' ? 'P' : 'S'
        } else if (tCode == 'A' && isAgent) {
            orderType = 'P'
        }
        let params = {
            newOrder: true,
            orderType,
            isAgent: isAgent || null,
            type: 'OrderBaseInfoPage',
            queryType: 'ORDER_ADD',
            bizMode: tCode === 'C' ? '1' : '0',
            isAll: true,
            callBack: (selectData) => { this._providerCb(selectData, typeStr, isAgent) }
        }

        if (tCode == 'QH' || tCode == 'E') {
            let { orderType, tCode } = this.orderFlag || {};
            let isQh = tCode == 'QH' ? true : false;
            let titleName = GET_R_TITLE_NAME(orderType, tCode);
            this.props.navigation.navigate('LongFrameListPage', { isQh, orderType, tCode, titleName, periodType: 'S' })
            return
        }

        if (tCode === 'C') {
            console.log('this.sendBuyData.orderInfo.companyId', this.sendBuyData.orderInfo.companyId)
            console.log('this.sendData.orderInfo.companyId', this.sendData.orderInfo.companyId)
            let companyIdBuy = this.sendBuyData.orderInfo.companyId || null;
            let companyIdSell = this.sendData.orderInfo.companyId || null;

            if (typeStr == 'buy') {// 排除 闭口订单 选择相同的 企业
                if (companyIdSell) params.companyIdBuy = companyIdSell;
            } else {
                if (companyIdBuy) params.companyIdBuy = companyIdBuy;
            }
        }
        this.props.navigation.navigate('SeachSupplierPage', params)
    }

    //是否选了一级商品
    _isGoodsFirst = () => {
        let result = false;
        let { orderItemList } = this.sendData || {};
        orderItemList && orderItemList.map(item => {
            if (item.transLevel == 1) {
                result = true;
            }
        })
        return result;
    }

    //资信评级控制 收款/付款类型
    _filterCredit = (companyCreditLevel) => {
        let { tCode, orderType } = this.orderFlag;
        let { orderItemList } = this.sendData || {};

        //if (!orderItemList || orderItemList.length == 0) return console.log('没商品不走');

        let isFirst = this._isGoodsFirst(orderItemList);

        console.log('companyCreditLevel', companyCreditLevel, isFirst)
        // 编辑清空原来的收款/付款类型 数据
        if (companyCreditLevel == 1 && (tCode == 'S' || tCode == 'C')) {
            this.sendData.orderInfo.payType = null;
        }

        //根据资信评级 控制授信单子 
        if (companyCreditLevel === 1 && isFirst) {  // 不支持售信单子
            if (tCode == "S") {  // 现货
                let lsArr = [];
                this.payTypeData && this.payTypeData.forEach((item) => {
                    if (orderType == 'S') {
                        if (item.dictKey == "4") {
                            lsArr.push(item);
                        }
                    } else {
                        if (item.dictKey == "3" || item.dictKey == "5") {
                            lsArr.push(item);
                        }
                    }
                })
                this.payTypeData = lsArr;
            }
        } else if (tCode === 'S') {
            this.payTypeData = this.inPayTypeData;
        }

        //一级 不支持选择国内信用证
        if (companyCreditLevel === 1 && isFirst) {
            //处理历史数据
            if ((tCode == 'S' || tCode == 'C') && this.sendData.orderInfo.payStyle == '3') {
                this.sendData.orderInfo.payStyle = null;
            }
            let lsPayMethodData = [];
            this.payMethodData && this.payMethodData.forEach(item => {
                if (item.dictKey != '3') {
                    lsPayMethodData.push(item);
                }
            })
            this.payMethodData = lsPayMethodData;
        } else {
            this.payMethodData = this.payMethodDataOld;
        }


        console.log('企业一级控制', this.payTypeData, JSON.stringify(this.payTypeData))
    }



    //选择供应商/客户-返回数据
    _providerCb = async (selectData, typeStr, isAgent) => {
        //白名单 清空
        this._clearPayTypeData();
        this.sendData.orderInfo.payType = null;


        let { tCode, orderType } = this.orderFlag;
        let { companyName, companyId, companyCreditLevel, whiteCredit } = selectData;

        let companyNameBuy = this.sendBuyData.orderInfo.companyName || '';
        let companyIdBuy = this.sendBuyData.orderInfo.companyId || null;
        let companyNameSell = this.sendData.orderInfo.companyName || '';
        let companyIdSell = this.sendData.orderInfo.companyId || null;
        //过滤授信
        this._filterCredit(companyCreditLevel);

        //中化泉州 特例
        if ('10cdixbijk3kdawx85r3hkqsc' == companyId && orderType == "P") {
            this.sendData.orderInfo.isUnite = '1';
        }

        if (tCode == 'C') {  // 闭口采购特殊
            this._claerData();
            // 重新选择供应商/客户  数据全部清空
            if (typeStr == 'buy') {
                if (this.sendBuyData.orderInfo.companyId === companyId) return;
                this.sendBuyData.orderInfo.companyId = companyId;
                this.sendBuyData.orderInfo.companyName = companyName;
                this.sendData.orderInfo.companyId = companyIdSell;
                this.sendData.orderInfo.companyName = companyNameSell;
                //资信评级
                this.sendBuyData.orderInfo.companyCreditLevel = companyCreditLevel;
                this.creditLevelBuy = companyCreditLevel;
            } else {
                if (this.sendData.orderInfo.companyId === companyId) return;
                this.sendBuyData.orderInfo.companyId = companyIdBuy;
                this.sendBuyData.orderInfo.companyName = companyNameBuy;
                this.sendData.orderInfo.companyId = companyId;
                this.sendData.orderInfo.companyName = companyName;
                //资信评级
                this.sendData.orderInfo.companyCreditLevel = companyCreditLevel;
                this.creditLevelSell = companyCreditLevel;
            }
        } else if (isAgent == 'Y') { // 代理
            this.sendData.orderInfo.agencyCompanyId = companyId;
            this.sendData.orderInfo.agencyCompanyName = companyName;
            //资信评级
            this.sendData.orderInfo.companyCreditLevel = companyCreditLevel;
            this.creditLevelSell = companyCreditLevel;
        } else { //其它订单
            if (this.sendData.orderInfo.companyId === companyId) return;
            if (isAgent == 'Y') {
                this._claerData();
            }
            this.sendData.orderInfo.companyId = companyId;
            this.sendData.orderInfo.companyName = companyName;
            //资信评级
            this.sendData.orderInfo.companyCreditLevel = companyCreditLevel;
            this.creditLevelSell = companyCreditLevel;
        }
        if (tCode != 'C') {
            this.setState({ status: 'loading' });
            await this.trustFn();
            this.setState({ status: 'data' });
        }
        if (tCode == 'C' && (!this.sendData.orderInfo.companyId || !this.sendBuyData.orderInfo.companyId)) {
            return false;
        }

        //客户为风控白名单类型过滤
        if (orderType == 'S' && tCode != 'C' && whiteCredit == '1') {
            this.whiteCredit = '1';
        } else {
            this.whiteCredit = '0';
        }
        this.setState({ ls: true })
    }

    //文本域书写
    _writeTextFn = (data) => {
        this.sendData.orderInfo[data.id] = data.text;
        // this.setState({ ls: true })
    }

    // 定金比例/几天内付款
    _writeCallBack = (objData) => {
        let keyStr = objData.name;
        if (objData.value == '') {
            this.sendData.orderInfo[keyStr] = null;
        } else {
            this.sendData.orderInfo[keyStr] = parseFloat(objData.value);
        }
        this.payTypeArr && this.payTypeArr.map(item => {
            if (keyStr === item.name) {
                item.value = objData.value
            }
        })


        console.log('objData', objData)
    }


    /* --------------------地址/运输方式/运输单价 strat-------------------- */


    //是否有运输方式
    _isTransport = () => {
        let { orderType, tCode } = this.orderFlag;
        let result = false;
        let { deliveryType } = this.sendData.orderInfo || {};
        if (tCode != 'C') {
            if (orderType == 'S' && (deliveryType == 'S' || deliveryType == 'P')) { //销售
                result = true;
            } else if (orderType == 'P' && (deliveryType == 'T' || deliveryType == 'S')) {
                result = true;
            }
        }
        return result;
    }

    //是否有 运承担 途损 运费成本
    _isFreight = () => {
        let result = false;
        let { orderType, tCode } = this.orderFlag;
        let { deliveryType } = this.sendData.orderInfo || {};
        if (tCode != 'C') {
            if (orderType == 'S' && (deliveryType == 'S' || deliveryType == 'P')) { //销售
                result = true;
            } else if (orderType == 'P' && (deliveryType == 'T' || deliveryType == 'S')) {
                result = true;
            }
        }
        return result
    }





    // 地址回调函数
    _addressCallback = (addressParams) => {
        let lsName = addressParams.id == 'srcAddressId' ? 'srcAddress' : 'destAddress';
        this.sendData.orderInfo[addressParams.id] = addressParams.addrId;
        this.sendData.orderInfo[lsName] = addressParams.value;
        this.setState({ ls: true })
    }


    // 地址/运输方式/运输单价 dome
    _addressView = () => {
        let { deliveryType, lostRender, lostRenderName, } = this.sendData.orderInfo;
        let { tCode, orderType } = this.orderFlag;
        return (
            <View>
                {/* 选择地址-其他模式 */}
                {/* 采购 */
                    tCode != 'QH' && tCode != 'C' && orderType == 'P' ? (
                        <View>
                            {
                                deliveryType && deliveryType != 'S' ? this._renderAddressSelect({ title: '出库地', id: 'srcAddressId', value: this.sendData.orderInfo.srcAddress || null, info: deliveryType != 'S' ? '落合同' : false }) : null
                            }
                            {
                                (deliveryType && deliveryType != 'U' && deliveryType != 'Q') ? this._renderAddressSelect({ title: '目的地', id: 'destAddressId', value: this.sendData.orderInfo.destAddress || null, info: deliveryType == 'S' ? '落合同' : false }) : null
                            }
                        </View>
                    ) : null
                }
                {/* 销售 */
                    tCode != 'QH' && tCode != 'C' && orderType == 'S' ? (
                        <View>
                            {
                                deliveryType && (deliveryType != 'P') ? this._renderAddressSelect({ title: '出库地', id: 'srcAddressId', value: this.sendData.orderInfo.srcAddress || null, info: (deliveryType == 'U' || deliveryType == 'T') ? '落合同' : false }) : null
                            }
                            {
                                deliveryType && (deliveryType == 'S' || deliveryType == 'P') ? this._renderAddressSelect({ title: '目的地', id: 'destAddressId', value: this.sendData.orderInfo.destAddress || null, info: (deliveryType == 'P' || deliveryType == 'S') ? '落合同' : false }) : null
                            }
                        </View>
                    ) : null
                }
                {/* 泉化 */
                    tCode == 'QH' ? (
                        <View>
                            {deliveryType === 'P' || deliveryType === 'S' ? this._renderAddressSelect({ title: '目的地', id: 'destAddressId', value: this.sendData.orderInfo.destAddress || null, info: (deliveryType == 'P' || deliveryType == 'S') ? '落合同' : false }) : null}
                        </View>
                    ) : null
                }
                {/* 运输方式 */}
                {
                    this._isTransport() ? this._activeFn() : null
                }


                {/* 运损承担 */}
                {
                    this._isFreight() ? (tCode == 'QH' || tCode == 'E' ? this._showview('运损承担', lostRenderName + '承担') : <RadiusGroupCpt data={{
                        title: '运损承担',
                        required: true,
                        listData: this.lossData,
                        selectedKey: lostRender,
                        _radiusItemFn: this._radiusItemFn,
                        id: 'lostRender'
                    }} />) : null
                }


                {/* {!this._isCKX() && isLostRate && (tCode == 'QH' || tCode == 'E' ? this._showview('运损承担', lostRenderName + '承担') : <RadiusGroupCpt data={{
                    title: '运损承担',
                    required: true,
                    listData: this.lossData,
                    selectedKey: lostRender,
                    _radiusItemFn: this._radiusItemFn,
                    id: 'lostRender'
                }} />)} */}

                {this._isFreight() && this._lostRateFn()}

                {/* 额外运费 */}
                {
                    tCode == 'QH' ? this._QhYunshu() : (!this._isCKX() ? this._Yunshu() : null)
                }
                {this._yfcb()}
            </View>
        )

    }

    // 渲染地址封装
    _renderAddressSelect = (addressParams) => {
        let { orderType, tCode } = this.orderFlag;
        let { deliveryType, companyId, companyName, agencyCompanyId, agencyCompanyName } = this.sendData.orderInfo;
        let { title, id, info, value } = addressParams;
        if (id == 'srcAddressId') {
            this.isVerify.startAddress = true;
        } else {
            this.isVerify.endAddress = true;
        }
        return (
            <AddressCpt data={{
                id, title, info, value,
                navigation: this.props.navigation,
                paramsData: {
                    tCode, orderType, companyId, deliveryType, agencyCompanyId, agencyCompanyName,
                    companyName
                },
                addressCallback: this._addressCallback,
            }} />
        )
    }

    _Yunshu = () => {
        return null;
    }

    _QhYunshu = () => {
        let { deliveryType, logisticsPrice, currency } = this.sendData.orderInfo;
        return (deliveryType == 'S' || deliveryType == 'P' || deliveryType == 'T') ? <FormItem required={true} keyboardType={'numeric'} handleCallBack={(text) => { this.sendData.orderInfo.logisticsPrice = text; }} placeHolder={'请输入额外运费'} label={'额外运费'} value={logisticsPrice} rightText={CURRENCY.getUnit(currency).text + '/吨'} type={'input'} /> : null;
    }






    _showview = (title, value, icon) => {
        return (
            <View style={orderBaseStyle.radioBox}>
                <Text style={orderBaseStyle.radioTitle}>{title}</Text>
                <Text style={orderBaseStyle.activeFonts}>{icon ? '千分之' : ''}{value}</Text>
                {icon && <Text> ({icon})</Text>}
            </View>
        )
    }

    _activeFn = () => {
        let { transportType, deliveryType, transportTypeName } = this.sendData.orderInfo;
        let { tCode } = this.orderFlag;
        return (deliveryType ? (tCode == 'QH' ? this._showview('运输方式', transportTypeName) : <RadiusGroupCpt data={{
            title: '运输方式',
            required: true,
            listData: this.transportTypeData,
            selectedKey: transportType,
            _radiusItemFn: this._radiusItemFn,
            id: 'transportType'
        }} />) : null)
    }

    _lostRateFn = () => {
        let { contractStandard, lostRateBig } = this.sendData.orderInfo;
        let arrowImg = require('../../../imgs/arrowBlue.png')
        let { tCode } = this.orderFlag;
        let timeStamp = new Date().getTime();
        return (
            tCode == 'QH' || tCode == 'E' ? this._showview('途损率', lostRateBig, contractStandard == 0 ? '非标' : '标准') : (
                <View style={{ paddingRight: 15 * scale }}>
                    <TouchableOpacity style={orderBaseStyle.lostRate} onPress={() => { this._beforeModalOpen() }}>
                        <Image source={arrowImg} style={{ transform: [{ 'rotate': '90deg' }], height: 12 * scale }} />
                        <Text style={orderBaseStyle.standard}>{contractStandard == 0 ? '非标' : '标准'}</Text>
                    </TouchableOpacity>
                    <FormItem key={timeStamp} sizeType={'small'} editable={contractStandard == 0} keyboardType={'numeric'} handleCallBack={this._lostRate} required={true} placeHolder={'请输入'} label={'途损率'} value={lostRateBig} rightText={'千分之'} type={'input'} />
                </View>
            )
        )
    }

    //如果是敞口销 客户自提 
    _isCKX = () => {
        let { tCode, orderType } = this.orderFlag;
        let { orderInfo } = this.sendData;
        let { deliveryType } = orderInfo || {};
        let result = false;
        if (tCode == 'S' && orderType == 'S' && deliveryType == 'T') {
            result = true;
        }
        return result;
    }




    _beforeModalOpen = async () => {
        let { orderInfo } = this.sendData;
        let { orderType, deliveryType, transportType } = orderInfo || {};
        // 液体商品
        if (this._isLiquidGoods()) {
            if (!orderType) {
                ToastUtil.showWarning("订单类型不能为空");
                return false;
            } else if (!deliveryType) {
                ToastUtil.showWarning("请先选择交货方式");
                return false;
            } else if (!transportType) {
                ToastUtil.showWarning("请先选择运输方式");
                return false;
            }
            if (this._islost()) {
                console.log('走接口')
                this.lostRateData = await this._lostRateData();
            } else {
                console.log('走存储')
                this.lostRateData = this.lostRateDataOld;
            }
        } else {
            this.lostRateData = this.lostRateDataOld;
        }
        this.setState({
            lostRateVisible: true
        })
    }

    _closeModal = (str) => {
        console.log('str', str)
        this.setState({
            [str]: false
        })
    }

    //contractStandard 0非标  1标准
    _lostRateCallBack = (index) => {
        if (index == 0) {
            this.sendData.orderInfo.lostRateBig = '';
            this.sendData.orderInfo.contractStandard = 0;
        } else {
            this.sendData.orderInfo.lostRateBig = this.lostRateData[index].dictName
            this.sendData.orderInfo.contractStandard = 1;
        }
        this.setState({
            lostRateIndex: index,
        }, () => {
            console.log('this.sendData.orderInfo', this.sendData.orderInfo)
            this._closeModal('lostRateVisible')
        })
    }

    //替哪个部门采
    _branchCallBack = (index) => {
        console.log('index', index, this.branchData)
        this.sendData.orderInfo.purchaseOrganId = this.branchData[index].organId;
        this.sendData.orderInfo.purchaseOrganName = this.branchData[index].organName;
        this.setState({
            branchIndex: index
        }, () => {
            this._closeModal('branchVisible')
        })
    }

    //途损率
    _lostRate = (str) => {
        this.sendData.orderInfo.lostRateBig = str;
    }

    /* ---------------------地址/运输方式/运输单价 end------------------------- */



    //单选按钮回调函数
    _radiusItemFn = (itemData, id, indexKey, type) => {
        let { tCode, orderType } = this.orderFlag;

        if (type == 'clearGoods') {
            this.sendData.orderItemList = [];
            this.sendData.orderInfo[id] = itemData;/* ----公共赋值部分--- */
            this.setState({ ls: true })
            return false;
        }


        this.sendData.orderInfo[id] = itemData;/* ----公共赋值部分--- */
        console.log('itemData', itemData, id, indexKey)
        if (id == 'isUnite') {
            this._clearFee();
        }
        if (id == 'payType') { /* ---付款类型--- */
            this.payTypeArr = this.payTypeData[indexKey] && this.payTypeData[indexKey].comments ? eval(this.payTypeData[indexKey].comments) : [];

            this.sendData.orderInfo.fundCreditFee = null; // 资金(授信)


            //清空运输方式
            if (tCode == 'S' && orderType == 'S') {
                this.sendData.orderInfo.transportType = null;
                console.log('清空一下99999999')
            }

            //白名单的时候 清空一下 交货方式
            if (itemData == '6') {
                this.sendData.orderInfo.deliveryType = null;
                this.sendData.orderInfo.transportType = null;
            }


            this._showPriceFn(this._changeSend()); // 类型修改 重新计算
            this.setState({
                trustShow: this.judgeTrust(itemData)
            }, () => {
                this._clearPayTypeData(this.payTypeArr);
            })
        }
        if (id == 'payStyle') {
            this.sendData.orderInfo.fundVoucherFee = null; // 资金（票据）
            this.sendData.orderInfo.voucherExpireDays = null; // 票据期限-天数
            this._showPriceFn(this._changeSend()); // 类型修改 重新计算
        }

        if (id == 'deliveryType') {/* ---交货方式--- */
            //清空地址
            this.sendData.orderInfo.srcAddress = null;
            this.sendData.orderInfo.destAddress = null;
            this.sendData.orderInfo.srcAddressId = null;
            this.sendData.orderInfo.destAddressId = null;
            this.isVerify.startAddress = null;
            this.isVerify.endAddress = null;
            this._clearFee();

            if (tCode == 'S') {
                this.sendData.orderInfo.lostRender = null;
                this.sendData.orderInfo.lostRenderName = null;
                this.sendData.orderInfo.lostRateBig = null;
                this.sendData.orderInfo.lostRate = null;
            }

            //清空运输方式
            if (tCode != 'QH') {
                this.sendData.orderInfo.transportType = null;
            }

            //清空额外运费
            this.sendData.orderInfo.logisticsPrice = null;

            //清空运费单价
            this.sendData.orderInfo.logisticsFee = null;

            //运承担
            //this.sendData.orderInfo.lostRender = null;

            // 现货(采)提示
            if (itemData == 'Q' && orderType == 'P') {
                this._infoP();
            }
            // 现货(销)提示
            if (itemData == 'P' && orderType == 'S') {
                this._infoS();
            }
            //假如是液体商品 控制途损率
            if (this._isLiquidGoods() && tCode == "S") {
                this.sendData.orderInfo.lostRateBig = null;
                this.sendData.orderInfo.lostRate = null;
            }
            this.setState({ ls: true })
        }

        // 运输方式 
        if (id == 'transportType' && this._isLiquidGoods() && tCode == "S") {
            this.sendData.orderInfo.lostRateBig = null;
            this.sendData.orderInfo.lostRate = null;
            this._clearFee();
            this.setState({ ls: true })
        } else if (id == 'transportType') {
            this._clearFee();
            this.setState({ ls: true })
        }

        if (id == 'isUnite' || id == 'payStyle' || id == 'payType') {
            this.setState({ ls: true })
        }
        console.log('this.sendData', this.sendData);
    }

    _isLostRateFn = (key) => {
        let { tCode, orderType } = this.orderFlag;
        let result = true;
        if (orderType == 'P') {
            if (key === 'U' || key == 'Y' || key == 'T') result = false;
        }
        return result;
    }

    _infoP = () => {
        Alert.alert('提示', `自提条款的货权转移场景，实际无物流，入库后进行货转或者派车自提，支持入库，不支持直销。如果是直销场景，对应销售需要下游客户自主去供应商处提货，请选择我司自提。`, [
            {
                text: '知道了',
            }
        ])
    }
    _infoS = () => {
        Alert.alert('提示', `直销场景，不由化销配送，货不从化销外租库出库，而是由上游供应商自主配送给下游客户。如果部分量需要化销配送，或者不确定是否是直销，请选择我司配送。`, [
            {
                text: '知道了',
            }
        ])
    }



    //清空付款类型相关数据
    _clearPayTypeData = (payTypeArr) => {
        this.sendData.orderInfo.deliveryExpireDays = null;
        this.sendData.orderInfo.payExpireDays = null;
        this.sendData.orderInfo.prepayRate = null;
    }

    //简单判断几位小数
    _verThreeFn = (str) => {
        str = isNaN(str) ? str : str + '';
        if (typeof (str) == 'string') {
            let lsArr = str.split('.');
            return lsArr[1] && lsArr[1].length
        }
        return 0;
    }

    //额外运费
    _isEwaiYf = () => {
        let { orderInfo } = this.sendData || {};
        let { deliveryType } = orderInfo;
        let { tCode, orderType } = this.orderFlag;
        let result = false;
        if (tCode == "QH" && deliveryType == 'S') {
            result = true;
        }
        console.log('result-999999', result)
        return result;
    }

    // 验证
    _verifyFn = () => {
        let { orderInfo, orderItemList, orderDeliveryPlanList } = this.sendData || {};
        let { companyId, payType, tradeType, payStyle, deliveryType, lostRender, lostRateBig,
            srcAddressId, destAddressId, transportType, logisticsFee, fundCreditFee, fundVoucherFee, voucherExpireDays, logisticsPrice, isUnite,
            deliveryExpireDays, companyCreditLevel, payExpireDays, prepayAmtBalanceDate } = orderInfo || {};
        let { orderType, tCode } = this.orderFlag;
        let { trustShow } = this.state;

        //一级企业一级商品付款天数须小于等于3天
        if (OrderCreateMethods._payExpireDays({ orderFlag: this.orderFlag, orderInfo, orderItemList }, true)) return false;

        //授信账期-1  闭口在里面判断 因为有采销俩份
        if (tCode != 'C' && OrderCreateMethods._isSxzq(orderType, payType)) {
            if (Utils.isEmpty(deliveryExpireDays)) {
                ToastUtil.showWarning(`请输入${orderType == 'P' ? '预付' : '赊销'}(授信)账期天数`);
                return false;
            } else if (isNaN(deliveryExpireDays)) {
                ToastUtil.showWarning(`${orderType == 'P' ? '预付' : '赊销'}(授信)账期天数不是有效数字`);
                return false;
            } else if (parseFloat(deliveryExpireDays) < 0) {
                ToastUtil.showWarning(`${orderType == 'P' ? '预付' : '赊销'}(授信)账期天数必须大于等于0`);
                return false;
            }
        }

        //资金（授信）
        if (!isUnite && isUnite != 0) {
            ToastUtil.showWarning('请选择业务类型');
            return false;
        }

        //资金（授信）
        if (tCode != "C" && this._isZjcbSx() && !fundCreditFee && fundCreditFee != 0) {
            ToastUtil.showWarning('请输入资金（授信）');
            return false;
        }
        //资金（票据）
        if (tCode != "C" && this._isZjcbPj() && !fundVoucherFee && fundVoucherFee != 0) {
            ToastUtil.showWarning('资金（票据）');
            return false;
        }
        //资金（票据）
        if (tCode != "C" && this._isZjcbPj() && !voucherExpireDays && voucherExpireDays != 0) {
            ToastUtil.showWarning('票据期限-天数');
            return false;
        }
        //运费成本
        if (logisticsFee != 0) {
            if (this._checkYfcb() && !logisticsFee) {
                ToastUtil.showWarning('请输入运费成本');
                return false;
            }
        }

        //运费成本
        if (tCode != 'QH' && this._verThreeFn(logisticsFee) > 2) {
            ToastUtil.showWarning('运费成本不能大于3位小数');
            return false;
        }

        if (this._isEwaiYf() && (!logisticsPrice || logisticsPrice == '')) {
            ToastUtil.showWarning('请输入额外运费');
            return false;
        }



        //供应商/客户-验证
        if (!companyId) {
            ToastUtil.showWarning(`请选择${this.PageText.companyTitle}`);
            return false;
        }

        //付款类型-验证
        if (!payType) {
            ToastUtil.showWarning(`请选择${this.PageText.payTypeTitle}`);
            return false;
        } else if (tradeType !== 'O') {
            let payTypeArrPass = true;
            this.payTypeArr && this.payTypeArr.map(item => {
                if (orderInfo[item.name] === '' || orderInfo[item.name] === null || orderInfo[item.name] === undefined) {
                    ToastUtil.showWarning(`请先填写完整${this.PageText.payTypeTitle}相关数据`);
                    payTypeArrPass = false;
                    return;
                }
                if (item.name === 'prepayRate' && Number.parseFloat(orderInfo[item.name]) <= 0) {
                    ToastUtil.showWarning(`保证金/定金比例必须大于0`);
                    payTypeArrPass = false;
                    return;
                }
                if (item.name === 'prepayAmtBalanceDate' && new Date(orderInfo[item.name]).getTime() < new Date(moment().format('YYYY-MM-DD')).getTime()) {
                    ToastUtil.showWarning(`尾款截止日期须大于等于当天时间`);
                    payTypeArrPass = false;
                    return;
                }
                /* if (trustShow && orderType === 'P' && item.name === 'deliveryExpireDays') {
                    if (Number.parseFloat(orderInfo[item.name]) > Number.parseFloat(this.showData.accountDay)) {
                        ToastUtil.showWarning(`本单授信账期必须小于等于授信账户账期天数`);
                        payTypeArrPass = false;
                        return;
                    }
                } */
                if (trustShow && orderType === 'S' && item.name === 'payExpireDays') {
                    if (Number.parseFloat(orderInfo[item.name]) > Number.parseFloat(this.showData.accountDay)) {
                        ToastUtil.showWarning(`付款天数必须小于等于账期天数`);
                        payTypeArrPass = false;
                        return;
                    }
                }
            })
            if (trustShow && orderType === 'P' && tCode != 'C') {
                if (Number.parseFloat(orderInfo.deliveryExpireDays) > Number.parseFloat(this.showData.accountDay)) {
                    ToastUtil.showWarning(`本单授信账期必须小于等于授信账户账期天数`);
                    payTypeArrPass = false;
                    return;
                }
            }

            if (!payTypeArrPass) return payTypeArrPass
        }

        //付款(收款)方式-验证
        if (!payStyle) {
            ToastUtil.showWarning(`请选择${this.PageText.payMethodTitle}`);
            return false;
        }

        //交货方式-验证
        if (!deliveryType) {
            ToastUtil.showWarning('请先选择交货方式');
            return false;
        }

        //交货地验证
        if (this.isVerify.startAddress && !srcAddressId) {
            ToastUtil.showWarning('请先选择出库地');
            return false;
        }
        if (this.isVerify.endAddress && !destAddressId) {
            ToastUtil.showWarning('请先选择目的地');
            return false;
        }
        //运输方式
        if (this._isTransport() && !transportType) {
            ToastUtil.showWarning('请先选择运输方式');
            return false;
        }

        if (this._isFreight()) {
            //运损承担方-验证
            if (!lostRender) {
                ToastUtil.showWarning('请先选择运损承担方');
                return false;
            }

            //途损率-验证
            if (!lostRateBig && lostRateBig !== 0 && lostRateBig !== '0') {
                ToastUtil.showWarning('请输入途损率');
                return false;
            }
        }
        //商品列表验证
        if (!orderItemList || (orderItemList && orderItemList.length <= 0)) {
            ToastUtil.showWarning('请添加商品');
            return false
        }
        if (orderItemList && orderItemList.length) {
            let goodsMore = false;
            orderItemList && orderItemList.map(item => {
                if (item.quantity == '' || item.quantity == null) {
                    goodsMore = true;
                }
            })
            if (goodsMore) {
                ToastUtil.showWarning('请完善商品信息');
                return false
            }
        }
        // 商品组限制
        if (orderItemList && orderItemList.length) {
            let isTheSameGoods = false;
            let lsStr = orderItemList[0].bizTeamId;
            orderItemList && orderItemList.forEach(item => {
                if (lsStr != item.bizTeamId) {
                    isTheSameGoods = true;
                }
            })
            if (isTheSameGoods) {
                ToastUtil.showWarning(`请选择同一个产品组的商品`);
                return;
            }
        }
        //交货计划列表
        if (tCode != 'QH' && !orderDeliveryPlanList) {
            ToastUtil.showWarning('请添加交货计划');
            return false
        }
        if (tCode != 'QH' && orderDeliveryPlanList && orderDeliveryPlanList.length <= 0) {
            ToastUtil.showWarning('请添加交货计划');
            return false
        } else if (tCode != 'QH' && orderDeliveryPlanList && orderDeliveryPlanList.length > 0) {
            //是否填完
            let more = false;
            orderDeliveryPlanList && orderDeliveryPlanList.forEach(item => {
                if (item.quantity == '' || item.quantity == null || item.deliveryBeginDate == '' || item.deliveryBeginDate == null || item.deliveryEndDate == '' || item.deliveryEndDate == null) {
                    more = true;
                }
            })
            if (more) {
                ToastUtil.showWarning('交货计划量请填写完整');
                return false
            }

            //总量控制
            let result = 0;
            orderDeliveryPlanList && orderDeliveryPlanList.forEach(item => {
                result = MethodUtil.countObj.add(item.quantity, result)
            })
            if (result > this._amount()) {
                ToastUtil.showWarning('交货计划量不能大于商品总量');
                return false
            }
            //排查尾款时间点 是否在交货计划时间段内
            if (payType === "2" && !OrderCreateMethods._moreTime(orderDeliveryPlanList, prepayAmtBalanceDate)) {
                ToastUtil.showWarning('尾款截止日须在交货时间范围内');
                return false
            }

        }
        console.log('恭喜 验证成功');
        return true;

    }


    //闭口参数特殊处理
    _changeSend = () => {
        let { tCode } = this.orderFlag;
        let paramsData = {};
        let { orderId } = this.props.navigation.state.params || {};
        let { orderInfo } = this.sendData || {};
        let { lostRateBig } = orderInfo;
        if (tCode == 'C') {
            // 闭口特殊处理(途损率)
            if (this.sendData.orderInfo.lostRateBig) {
                this.sendData.orderInfo.lostRate = MethodUtil.countObj.divide(this.sendData.orderInfo.lostRateBig, 1000, 4);
            }
            if (this.sendBuyData.orderInfo.lostRateBig) {
                this.sendBuyData.orderInfo.lostRate = MethodUtil.countObj.divide(this.sendBuyData.orderInfo.lostRateBig, 1000, 4);
            }
            paramsData.saleOrder = this.sendData;
            paramsData.saleOrder.orderInfo.orderType = 'S';
            paramsData.purchaseOrder = this.sendBuyData;
            paramsData.purchaseOrder.orderInfo.orderType = 'P';
        }
        // 途损率
        if (this._isFreight()) {
            this.sendData.orderInfo.lostRate = MethodUtil.countObj.divide(lostRateBig, 1000, 4);
        }
        // 泉化/长约 
        this.sendData.orderInfo.isQhXhXsBiz = tCode == 'QH' ? 'Y' : (tCode == 'E' ? 'N' : null);
        //长约订单(创建)
        if ((tCode == 'E' || tCode == 'QH') && !orderId && !this.relevanceOrderList) {
            this.sendData.orderInfo.longOrderId = this.orderId;
            this.sendData.orderInfo.orderId = null;
        }


        //提交特殊字段
        this.sendData.submit = 0; // 0 草稿  1 审批中
        //一键下单 去掉订单ID
        if (this.isHistory) {
            if (tCode == 'C') {
                paramsData.saleOrder.orderInfo.orderId = null;
                paramsData.purchaseOrder.orderInfo.orderId = null;
            } else {
                this.sendData.orderInfo.orderId = null;
            }
        }
        if (tCode == 'C' || tCode == 'QH') {
            this.sendData.submit = 1; // 代表新增字段
        }
        console.log('参数-普', this.sendData)
        console.log('参数-闭', paramsData)
        return tCode == 'C' ? paramsData : this.sendData;
    }


    //保存
    _saveFn = async (type) => {
        if (this.requesting) return;
        let { tCode, orderType } = this.orderFlag;
        this.setState({ status: 'loading' });
        this.requesting = true;
        await this._showPriceFn(this._changeSend());
        let resultData = await HTTP.POST(API_GENERATE(API['NEW_ORDER_OPEN_' + (tCode == 'QH' ? 'E' : tCode)]), this._changeSend());
        this.setState({ status: 'data' });
        console.log('保存成功', resultData)
        if (resultData) {

            //后续添回填数据
            if (tCode != 'C') {
                this.sendData.orderInfo.orderId = resultData.orderInfo.orderId;
                this.sendData.orderFeeList = resultData.orderFeeList;
                this.sendData.orderDeliveryPlanList = resultData.orderDeliveryPlanList;
                this.sendData.orderItemList = resultData.orderItemList;
            }

            setTimeout(() => {
                this.requesting = false;
            }, 1000)
            ToastUtil.showSuccess('已保存到草稿').then(() => {
                this.resetPage(orderType, tCode, 0)
            })
        } else {
            this.requesting = false;
        }
    }

    //提交(下一步)
    _nextFn = async () => {
        if (this.requesting) return;
        if (!this._verifyFn()) return
        let { tCode, orderType } = this.orderFlag;

        this.setState({ status: 'loading' });
        this.requesting = true;


        await this._showPriceFn(this._changeSend());

        let resultData = await HTTP.POST(API_GENERATE(API['NEW_ORDER_SUBMIT_' + (tCode == 'QH' ? 'E' : tCode)]), this._changeSend());
        this.setState({ status: 'data' });

        if (resultData) {
            this.requesting = false;
            //后续添回填数据
            if (tCode != 'C') {
                this.sendData.orderInfo.orderId = resultData.orderInfo.orderId;
                this.sendData.orderFeeList = resultData.orderFeeList;
                this.sendData.orderDeliveryPlanList = resultData.orderDeliveryPlanList;
                this.sendData.orderItemList = resultData.orderItemList;
            }
            resultData.orderFlag = this.orderFlag; // 添加一个标示对象 - 后面关联用
            this.isHistory = false; // 历史订单重新初始化
            console.log('保存成功-后续-提交参数', resultData)
            if (tCode == 'C' || tCode == 'A') {
                this.resetPage(orderType, tCode, 1)
            } else if (tCode == 'QH') {
                this.resetPage(orderType, tCode, 2)
            } else {
                this.props.navigation.navigate('relevanceOrderList', { resultData, showPrice: this.showPrice, orderFlag: this.orderFlag })
            }
        } else {
            this.requesting = false;
        }
    }

    //交货方式  type 获取 name
    _getDeliveryName = (type, typeData) => {
        let resultName = '';
        typeData && typeData.forEach(item => {
            if (item.dictKey == type) {
                resultName = item.dictName
            }
        })
        return resultName;
    }



    /* --------------------- 功能函数 start --------------- */


    /* 闭口 支付回调 运输信息回调 */
    _modalCallback = (payData) => {
        let { tCode } = this.orderFlag;
        console.log('闭口回调000009999999', payData)
        if (!payData) return;
        let { buyData, sellData } = payData;
        this.sendData.orderInfo = Object.assign({}, this.sendData.orderInfo, sellData)
        this.sendBuyData.orderInfo = Object.assign({}, this.sendData.orderInfo, buyData)

        // if (tCode == 'C') {//,闭口
        //     this.setState({ ls: true })
        // } else { // 长约
        //     this._showPriceFn(this._changeSend())
        // }
        this._showPriceFn(this._changeSend())
    }

    /* 交货计划回调 */
    _planDataCall = (planData, type) => {
        let { tCode } = this.orderFlag;
        if (tCode == 'C') {
            this.sendBuyData.orderDeliveryPlanList = planData;
        }
        this.sendData.orderDeliveryPlanList = planData;
        this.setState({ user: type == 'user' ? true : false })
    }



    /* 费用回调 */
    _feeCallback = (feeData) => {
        this.sendData.orderFeeList = feeData;
        this._showPriceFn(this._changeSend());
        // this.setState({ ls: true })
    }



    /* 商品回调 */
    _goodsCallback = (goodsData) => {
        console.log('goodsData-商品回显', goodsData)
        if (!goodsData) return;
        let { tCode } = this.orderFlag;
        this.sendData.orderItemList = goodsData;

        //假如是液体商品 控制途损率
        if ((tCode == "S" || tCode == "C") && goodsData.length && (goodsData[0].goodsState == 'FLUID' || goodsData[0].goodsState == 'GAS')) {
            if (tCode != 'C') {
                this.sendData.orderInfo.lostRateBig = null;
                this.sendData.orderInfo.lostRate = null;
            } else {
                this.sendData.orderInfo.deliveryType = null;
                this.sendData.orderInfo.lostRateBig = null;
                this.sendData.orderInfo.lostRate = null;
            }
        }

        //this._amount();
        if (tCode == 'C') {
            let lsArr = [];
            goodsData.forEach(item => {
                let lsItem = Object.assign({}, item)
                lsArr.push(lsItem)
            })
            this.sendBuyData.orderItemList = lsArr;
            goodsData && goodsData.map((item, index) => {
                //闭口去掉itemId
                if (tCode == 'C') {
                    this.sendBuyData.orderItemList[index].itemId = null;
                    this.sendData.orderItemList[index].itemId = null;
                }
                this.sendBuyData.orderItemList[index].udPrice = item.purchaseUdPrice;
                this.sendBuyData.orderItemList[index].price = item.purchasePrice;
                this.sendData.orderItemList[index].udPrice = item.saleUdPrice;
                this.sendData.orderItemList[index].price = item.salePrice;
            })

        }
        //如果企业是一级的,俩个商品等级不一样 要提示
        if ((this.creditLevelSell == '1' || this.creditLevelBuy == '1') && goodsData && goodsData.length > 1) {
            let first = '';
            let onOff = false;
            goodsData.forEach((item, index) => {
                if (index == 0) {
                    first = item.transLevel;
                } else if ((item.transLevel != first)) {
                    onOff = true;
                }
            })
            if (onOff) {
                ToastUtil.showWarning('当前商品交易等级不一致，系统按最小1级商品交易规则控制', 3500);
            }
        }

        this._filterCredit(this.creditLevelSell || this.creditLevelBuy);
        console.log('goodsData-123', goodsData)

        this._showPriceFn(this._changeSend());
        this.setState({ user: false })
    }

    // 计算量
    _amount = () => {
        let { orderItemList } = this.sendData;
        let result = 0;
        orderItemList && orderItemList.forEach(item => {
            result = MethodUtil.countObj.add(item.quantity, result)
        })
        if (result) {
            result = result + '';
        } else {
            result = null;
        }
        return result;
    }

    _goodsFn = () => {
        let { orderType, tCode, periodType } = this.orderFlag;
        let { orderInfo, orderItemList } = this.sendData;
        let { isUnite, organId, companyId, currency, companyName, logisticsPrice, agencyCompanyId, agencyCompanyName } = orderInfo || {};
        //闭口
        let companyNamebuy = this.sendBuyData.orderInfo.companyName;
        let companyIdbuy = this.sendBuyData.orderInfo.companyId;
        return <GoodsBlock data={{
            navigation: this.props.navigation, pageParams: {
                ysPercent: this.ysPercent,
                orderType,
                periodType, //长约合同->L   普通合同->S
                companyId,
                companyName,
                companyIdBuy: companyIdbuy,
                companyNameBuy: companyNamebuy,
                agencyCompanyId,
                agencyCompanyName,
                currency,   // 币种 单位
                isUnite,   //  业务类型
                tCode,
                hisCallback: this._hisCallback,
                logisticsPrice,
                creditLevelBuy: this.creditLevelBuy,
                creditLevelSell: this.creditLevelSell,
                organId
            },
            goodsCallback: this._goodsCallback,
            longFrameData: this.longFrameData || null,
            longFrameIdArr: this.iframeid || this.orderId,
            frameGoodsList: this.frameGoodsList,
            goodsEdit: orderItemList
        }} />
    }

    _okFn = () => {
        let { orderIndex } = this.props.navigation.state.params || {};
        this.props.navigation.state.params && this.props.navigation.state.params._detailCallback(orderIndex, this.sendData);
        this.props.navigation.goBack()
    }

    // 商品液体 涂损率 
    _lostRateData = async () => {
        let { orderInfo, orderItemList } = this.sendData;
        let { deliveryType, transportType } = orderInfo || {};
        let { orderType } = this.orderFlag;
        let resultData = await HTTP.POST(API_GENERATE(API.NEW_ORDER_LOSTRATE), { goodsId: orderItemList[0].goodsId, orderType, deliveryType, transportType })
        return resultData || [];
    }

    //判断是不是液体商品
    _isLiquidGoods = () => {
        let { orderItemList } = this.sendData;
        if (orderItemList && orderItemList.length && (orderItemList[0].goodsState == "FLUID" || orderItemList[0].goodsState == "GAS")) {
            return true;
        }
        return false;
    }


    //判断是不是要控制途损率
    _islost = () => {
        let { orderInfo } = this.sendData;
        let { deliveryType } = orderInfo || {};
        let { orderType } = this.orderFlag;
        let reset = false;

        if (orderType == "S") {
            if (deliveryType == 'P' || deliveryType == 'S') {
                reset = true;
            }
        } else if (orderType == "P") {
            if (deliveryType == 'S') {
                reset = true;
            }
        }
        return reset;
    }

    //隐藏/关闭详情弹框
    _hideDetials = (boolean) => {
        console.log('走外面调用', boolean)
        this.setState({
            isVisible: boolean
        })
    }

    //1,判断是否有 资金 授信 字段
    _isZjcbSx = () => {
        let result = false;
        let { orderType } = this.orderFlag;
        let { orderInfo } = this.sendData;
        let { payType } = orderInfo || {};
        if ((orderType == "S" && (payType == '5' || payType == '3')) || (orderType == "P" && (payType == '2' || payType == '4'))) {
            result = true;
        }
        return result;
    }

    //2.计算资金 
    _jsZjcbSx = (day) => {
        return MethodUtil.countObj.divide(MethodUtil.countObj.multiply(0.0435, day), 365, 6)
    }

    //3.资金 授信
    _zjcbSx = () => {
        let { orderType } = this.orderFlag;
        let { orderInfo } = this.sendData;
        let { fundCreditFee } = orderInfo || {};
        if (this._isZjcbSx()) {
            return <FormItem editable={false} key={new Date().getTime()} iconText={`资金（授信）=加权平均单价*${this.constProportion}%*${orderType == "S" ? '本单货到或票到天数' : '本单款到天数'}/365天`} keyboardType={'numeric'} handleCallBack={(text) => { this._writeCallBack({ name: 'fundCreditFee', value: text }) }} labelStyle={orderBaseStyle.labelStyle} required={true} sizeType={'small'} placeHolder={'公式'} label={'资金(授信)'} value={fundCreditFee} rightText={'元/吨'} rightTextStyle={{ fontSize: 12 * scale, color: '#333' }} inputStyle={{ textAlign: 'center' }} type={'input'} />
        }
        return null;
    }

    //1.判断是否有 资金 票据
    _isZjcbPj = () => {
        let result = false;
        let { orderType } = this.orderFlag;
        let { orderInfo } = this.sendData;
        let { payStyle } = orderInfo || {};
        if (orderType == 'S' && (payStyle == '2' || payStyle == '3')) {
            result = true;
        }
        return result;
    }


    //焦点回调 - 收款类型
    _blurWriteCallBack = (key) => {
        let { trustShow } = this.state || {};
        let { orderType } = this.orderFlag;
        let { orderInfo, orderItemList } = this.sendData;
        let { payExpireDays } = orderInfo || {};
        OrderCreateMethods._payExpireDays({ orderFlag: this.orderFlag, orderInfo, orderItemList });
        // 资金成本(授信)
        if (this._isZjcbSx() && ((orderType == 'P' && key == 'deliveryExpireDays') || (orderType == 'S' && key == 'payExpireDays'))) {
            if (orderType == 'S' && key == 'payExpireDays') { // 赊销(账期)天数 根据票到/货到多少天联动
                if (trustShow) {
                    this.sendData.orderInfo.deliveryExpireDays = this.sendData.orderInfo.payExpireDays;
                    if (Number.parseFloat(payExpireDays) > Number.parseFloat(this.showData.accountDay)) {
                        Alert.alert('提示', `授信账期时间需小于等于授信账期${this.showData.accountDay}天`, [
                            { text: '知道了', onPress: () => { console.log('确认') } }
                        ])
                    }
                }
            }
            this._showPriceFn(this._changeSend());
        }
    }

    //焦点回调 - 收款方式
    _blurWriteCallBack2 = (key) => {
        // 资金成本(授信)
        if (this._isZjcbPj() && key == 'voucherExpireDays') {
            this._showPriceFn(this._changeSend())
        }
    }


    //3.资金 票据
    _zjcbPj = () => {
        let { orderInfo } = this.sendData;
        let { fundVoucherFee, voucherExpireDays } = orderInfo || {};
        if (this._isZjcbPj()) {
            return <View style={orderBaseStyle.fklxBox}>
                <FormItem onBlurFn={() => { this._blurWriteCallBack2('voucherExpireDays') }} key={new Date().getTime() + Math.random()} keyboardType={'numeric'} handleCallBack={(text) => { this._writeCallBack({ name: 'voucherExpireDays', value: text }) }} labelStyle={orderBaseStyle.labelStyle} required={true} sizeType={'small'} placeHolder={'请输入'} label={'票据期限'} value={voucherExpireDays} rightText={'天'} rightTextStyle={{ fontSize: 12 * scale, color: '#333' }} inputStyle={{ textAlign: 'center' }} type={'input'} />
                <FormItem editable={false} key={new Date().getTime()} iconText={`资金（票据）=加权平均单价*${this.constProportion}%*本单票据期限天数/365天`} keyboardType={'numeric'} handleCallBack={(text) => { this._writeCallBack({ name: 'fundVoucherFee', value: text }) }} labelStyle={orderBaseStyle.labelStyle} required={true} sizeType={'small'} placeHolder={'公式'} label={'资金(票据)'} value={fundVoucherFee} rightText={'元/吨'} rightTextStyle={{ fontSize: 12 * scale, color: '#333' }} inputStyle={{ textAlign: 'center' }} type={'input'} />
            </View>
        }
        return null;
    }
    //校验用 运费成本   (涉及我司自提(T)，我司配送(S)的，运费成本必填)
    _checkYfcb = () => {
        let result = false;
        let { orderType } = this.orderFlag;
        let { deliveryType } = this.sendData.orderInfo;
        if ((orderType == 'S' && deliveryType == 'S') || (orderType == 'P' && deliveryType == 'T')) {
            result = true;
        }
        return result;
    }

    //判断 运费成本 
    _isYfcb = () => {
        let result = false;
        let { deliveryType } = this.sendData.orderInfo;
        let { orderType, tCode } = this.orderFlag;
        if (tCode == 'QH' && deliveryType == 'S') {
            result = true;
        } else if ((orderType == "P" && (deliveryType == 'Q' || deliveryType == 'T' || deliveryType == 'S')) || (orderType == "S" && (deliveryType == 'S' || deliveryType == 'P'))) {
            // if (tCode != 'QH') {  //泉化无 运费成本
            //     result = true;
            // }
            result = true;
        }
        return result;
    }
    //运费成本
    _yfcb = () => {
        let { logisticsFee, currency } = this.sendData.orderInfo;
        if (this._isYfcb()) {
            return <FormItem onBlurFn={() => { this._showPriceFn(this._changeSend()) }} required={this._checkYfcb() ? true : false} keyboardType={'numeric'} handleCallBack={(text) => { this.sendData.orderInfo.logisticsFee = text; }} placeHolder={'请输入'} label={'运费成本'} value={logisticsFee} rightText={CURRENCY.getUnit(currency).text + '/吨'} type={'input'} />
        }
        return null;
    }

    // 底部弹框 价格 校验是否有商品
    _isShowPriceFn = (sendData) => {
        let result = false;
        let { tCode } = this.orderFlag;
        //验证 是否有商品
        if (tCode == "C") { //闭口 判断销售一份
            let saleOrder = sendData.saleOrder || {};
            if (!(saleOrder.orderItemList && saleOrder.orderItemList.length)) {
                result = true;
                ToastUtil.showWarning('请先添加商品');
            }
        } else {
            if (!(sendData.orderItemList && sendData.orderItemList.length)) {
                result = true;
                ToastUtil.showWarning('请先添加商品');
            }
        }
        return result;
    }

    // 底部弹框 价格 费用展示
    _showPriceFn = async (sendData = {}) => {
        let { tCode } = this.orderFlag;
        //是否满足调用接口
        //if (this._isShowPriceFn(sendData)) return;

        let lsData = Object.assign(sendData);
        console.log('1111111', JSON.stringify(sendData))
        console.log('提交前-参数', lsData)
        let responseData = await OrderAPIService.showPrice(sendData);
        console.log('底部计算-结果', responseData);
        //根据结果 数据返回
        if (responseData) {
            this.showPrice = responseData;//底部展示用
            let { orderPriceItemList, orderPriceInfo } = responseData || {};

            //多商品
            orderPriceItemList && orderPriceItemList.forEach((item, index) => {
                this.sendData.orderItemList[index].barePrice = item.barePrice; // 裸价
                this.sendData.orderItemList[index].pocketPrice = item.pocketPrice; //落代价
                this.sendData.orderItemList[index].bareUdPrice = item.bareUdPrice; // 原始升贴水
                this.sendData.orderItemList[index].udPrice = item.udPrice; //合同升贴水
                this.sendData.orderItemList[index].price = item.price; //合同价
                if (tCode == 'C') {
                    this.sendBuyData.orderItemList[index].barePrice = item.purchaseOrderItem.barePrice; // 裸价
                    this.sendBuyData.orderItemList[index].pocketPrice = item.purchaseOrderItem.pocketPrice; //落代价
                }
            })

            // 根据计算结果 处理相对应的数据
            // 筛选字段
            this.sendData.orderInfo.fundVoucherFee = orderPriceInfo.fundVoucherFee;
            this.sendData.orderInfo.fundCreditFee = orderPriceInfo.fundCreditFee;
            this.sendData.orderInfo.voucherExpireDays = orderPriceInfo.voucherExpireDays;
            if (tCode == 'C') {//
                this.sendBuyData.orderInfo.fundVoucherFee = orderPriceInfo.purchaseOrderInfo && orderPriceInfo.purchaseOrderInfo.fundVoucherFee;
                this.sendBuyData.orderInfo.fundCreditFee = orderPriceInfo.purchaseOrderInfo && orderPriceInfo.purchaseOrderInfo.fundCreditFee;
                this.sendBuyData.orderInfo.voucherExpireDays = orderPriceInfo.purchaseOrderInfo && orderPriceInfo.purchaseOrderInfo.voucherExpireDays;
            }
        }
        this.setState({
            ls: true
        })
    }

    //现货采购、采购长约 有 替哪个部门采
    _isBranch = () => {
        let { orderType, tCode } = this.orderFlag;
        let isisBranch = false;
        if (orderType == "P" && (tCode == 'S' || tCode == 'E')) {
            isisBranch = true;
        }
        return isisBranch
    }

    //清空费用
    _clearFee = () => {
        console.log('清空费用')
        let { tCode } = this.orderFlag;
        let { orderFeeList } = this.sendData;
        if (orderFeeList && orderFeeList.length) {
            Alert.alert('提示', `重新选择将会清空费用预估`, [
                {
                    text: '确认', onPress: () => {
                        if (tCode == 'C') {
                            this.sendBuyData.orderFeeList = [];
                            this.sendData.orderFeeList = [];
                        } else {
                            this.sendData.orderFeeList = [];
                        }
                        this.setState({ ls: true })
                    }
                },
                {
                    text: '取消', onPress: () => {
                        console.log('	取消')
                    }
                }
            ])
        }
    }

    _branchFn = () => {
        let { tCode } = this.orderFlag;
        if (this.sendData.orderItemList && this.sendData.orderItemList.length) {
            Alert.alert('提示', `重新选择将会清空商品`, [
                {
                    text: '确认', onPress: () => {
                        if (tCode == 'C') {
                            this.sendBuyData.orderItemList = [];
                            this.sendData.orderItemList = [];
                        } else {
                            this.sendData.orderItemList = [];
                        }
                        this.setState({ branchVisible: true }, () => {
                            this._closeModal('branchVisible')
                        })
                    }
                },
                {
                    text: '取消', onPress: () => {
                        console.log('	取消')
                    }
                },
            ]);
        }
        this.setState({ branchVisible: true })
    }

    //白名单数据字典控制
    _whileFn = () => {
        let { tCode } = this.orderFlag;
        let { orderInfo, orderItemList } = this.sendData || {};
        let { deliveryType, payType, companyCreditLevel } = orderInfo || {};
        let isFirst = this._isGoodsFirst(orderItemList);
        console.log('000000---0000000', deliveryType, this.whiteCredit)
        if (tCode == 'C') return;
        if (this.whiteCredit == '1') { // 是白名单
            if (isFirst && companyCreditLevel === 1) {
                let newArr = this.inPayTypeData.filter((item) => { if (item.dictKey === '6') { return item; } });
                if (!this.payTypeData.some(item => { return item.dictKey === '6' })) {
                    this.payTypeData.push(newArr[0]);
                }
            } else {
                this.payTypeData = this.inPayTypeData;
            }

            if (payType == '6') { // 交货方式数据字典控制
                let lsArr = [];
                this.deliveryDataNew.forEach((item) => {
                    if (item.dictKey == 'S') {
                        lsArr.push(item);
                    }
                })
                this.deliveryData = lsArr;
            } else {
                this.deliveryData = this.deliveryDataNew;// 还原
            }

            if (deliveryType == "S" && payType == '6') { // 运输方式数据字典控制
                let lsArr = [];
                this.transportTypeDataOld.forEach((item) => {
                    if (item.dictKey == '1') {
                        lsArr.push(item);
                    }
                })
                this.transportTypeData = lsArr;
            } else {
                this.transportTypeData = this.transportTypeDataOld;
            }
        } else {
            let lsArr = [];
            this.payTypeData.forEach((item) => {
                if (tCode == 'S') {
                    if (item.dictKey != '6') {
                        lsArr.push(item);
                    }
                } else {
                    lsArr.push(item);
                }
            })
            this.payTypeData = lsArr;
        }
        console.log('------------', this.sendData, this.payTypeArr, this.payTypeData)
    }

    //过滤闭口的 白名单
    _payTypeDataFilter = (payTypeData) => {
        let resultArr = [];
        payTypeData && payTypeData.forEach((item) => {
            if (item.dictKey != '6') {
                resultArr.push(item);
            }
        })
        return resultArr
    }

    //授信账期
    _sxzq = () => {
        let { orderType } = this.orderFlag;
        let { orderInfo } = this.sendData || {};
        let { deliveryExpireDays, payType } = orderInfo || {};
        if (OrderCreateMethods._isSxzq(orderType, payType)) {
            return <FormItem
                onBlurFn={() => { this._sxzqBlurFn(orderType == 'P' ? 'deliveryExpireDays' : 'payExpireDays') }}
                iconText={`该天数为本单授信账期，系统会以此天数计算授信订单逾期日`}
                keyboardType={'numeric'}
                handleCallBack={(text) => { this._writeCallBack({ name: 'deliveryExpireDays', value: text }) }}
                labelStyle={orderBaseStyle.labelStyle}
                required={true}
                sizeType={'small'}
                placeHolder={orderType == 'S' ? '联动' : '请输入'}
                label={`${orderType == 'P' ? '预付' : '赊销'}(授信)账期`}
                value={Utils.numberToString(deliveryExpireDays)}
                rightText={'天'}
                rightTextStyle={{ fontSize: 12 * scale, color: '#333' }}
                inputStyle={{ textAlign: 'center' }}
                type={'input'}
                editable={orderType == 'S' ? false : true} />
        }
        return null;
    }
    //焦点离开 授信账期
    _sxzqBlurFn = (key) => {
        let { trustShow } = this.state;
        let { orderType } = this.orderFlag;
        let { orderInfo } = this.sendData || {};
        let { deliveryExpireDays } = orderInfo || {};

        if (trustShow && orderType == 'P' && key == 'deliveryExpireDays' && (Number.parseFloat(deliveryExpireDays) > Number.parseFloat(this.showData.accountDay))) {
            Alert.alert('提示', `授信账期时间需小于等于授信账期${this.showData.accountDay}天`, [
                { text: '知道了', onPress: () => { console.log('确认') } }
            ])
        }
        if (orderType === 'P') {
            this._showPriceFn(this._changeSend())
        }
        OrderCreateMethods._sxzqValidation(deliveryExpireDays, orderType);
    }





    render() {
        let { orderType, tCode, periodType } = this.orderFlag;
        let { trustShow, lostRateIndex, lostRateVisible, status, user, deliveryTypeIsX, isVisible, branchIndex, branchVisible } = this.state;
        let { orderInfo, orderFeeList, orderDeliveryPlanList, orderItemList } = this.sendData;
        let { payType, deliveryType, payStyle, transportType, isUnite, companyId, currency, companyName, remark, auditRemark, agencyCompanyName, agencyCompanyId, funds, purchaseOrganName, prepayAmtBalanceDate } = orderInfo || {};
        let { limitAmount, creditEndDate, isExpired, accountDay } = this.showData; // 授信展示数据
        let timeStamp = new Date().getTime();
        //闭口
        let companyNamebuy = this.sendBuyData.orderInfo.companyName;
        let companyIdbuy = this.sendBuyData.orderInfo.companyId;

        this._whileFn();
        let isLimit = OrderCreateMethods._deliveryDataLimit(this.creditLevelBuy, this.creditLevelSell, orderItemList);

        return (<View style={orderBaseStyle.container}>

            <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : null} keyboardVerticalOffset={20} >
                <View style={orderBaseStyle.scrollview}>
                    <ScrollView showsVerticalScrollIndicator={false} keyboardShouldPersistTaps={'handled'}>
                        <View style={[orderBaseStyle.box, orderBaseStyle.box3]}>
                            {tCode == 'A' ? (<FormItem handleCallBack={() => { this._providerAddFn(null, 'Y') }} required={true} value={agencyCompanyName} type="select" label={'供应商'} />) : null}
                            {tCode != 'C' ? (<FormItem handleCallBack={this._providerAddFn} disable={this.batch ? true : false} required={true} value={companyName} type="select" label={this.PageText.companyTitle} />) : null}
                            {tCode == 'C' ? (<FormItem handleCallBack={() => { this._providerAddFn('buy') }} required={true} value={companyNamebuy} type="select" label={'供应商'} />) : null}
                            {this.creditLevelBuy ? <Text style={orderBaseStyle.zxpj}>资信评级:{this.creditLevelBuy}级</Text> : null}
                            {tCode == 'C' ? (<FormItem handleCallBack={this._providerAddFn} required={true} value={companyName} type="select" label={'客户'} />) : null}
                            {this.creditLevelSell ? <Text style={orderBaseStyle.zxpj}>资信评级:{this.creditLevelSell}级</Text> : null}
                            {  //销售才可以选择（排除泉化的销售）
                                orderType == 'S' && tCode != 'QH' && tCode != 'C' ? (
                                    <RadiusGroupCpt data={{
                                        title: '业务类型',
                                        radioStyle: { justifyContent: 'flex-end' },
                                        required: true,
                                        listData: this.businessTypeData,
                                        selectedKey: isUnite,
                                        _radiusItemFn: this._radiusItemFn,
                                        id: 'isUnite',
                                        radioBox: orderBaseStyle.radioBoxTop,
                                        goodsData: orderItemList
                                    }} />
                                ) : null
                            }
                            {tCode === 'QH' ? <View style={orderBaseStyle.khzj}>
                                <Text style={orderBaseStyle.trust}>客户资金：</Text>
                                <Text style={[orderBaseStyle.trust, { marginLeft: 2 * scale, marginRight: 5 * scale }]}>￥{CURRENCY.format(funds)}</Text>
                            </View> : null}
                            {
                                this.branchData ? <FormItem handleCallBack={this._branchFn} required={true} value={purchaseOrganName} type="select" label={'替哪个部门采'} /> : null
                            }
                        </View>
                        {
                            companyId || agencyCompanyId ? (<View>
                                {this._goodsFn()}
                                {/* 支付信息 */}
                                {
                                    tCode == 'C' || tCode == 'E' || tCode == 'QH' ? <PayCBlock data={{
                                        navigation: this.props.navigation,
                                        initData: {
                                            creditLevelBuy: this.creditLevelBuy,
                                            creditLevelSell: this.creditLevelSell,
                                            isGoodsFirst: this._isGoodsFirst(),
                                            payTypeData: tCode == 'C' ? this._payTypeDataFilter(this.inPayTypeData) : this.payTypeData,
                                            payMethodData: tCode == 'C' ? this.payMethodDataOld : this.payMethodData,
                                            orderFlag: this.orderFlag,
                                            trustShow,
                                            creditData: this.showData
                                        },
                                        editData: {
                                            buyData: this.sendBuyData.orderInfo || {},
                                            sellData: this.sendData.orderInfo || {}
                                        },
                                        payCallback: this._modalCallback,
                                        jsPriceData: this._changeSend(),
                                        payEndTimeCallback: () => { this.DatePicker.show(); }
                                    }} /> : (
                                            <View style={orderBaseStyle.box}>
                                                <TitleCpt
                                                    data={{
                                                        title: '支付信息'
                                                    }} />
                                                <RadiusGroupCpt data={{
                                                    disable: true,
                                                    title: this.PageText.payTypeTitle,
                                                    required: true,
                                                    listData: this.payTypeData,
                                                    selectedKey: payType,
                                                    textStyleBox: orderBaseStyle.textStyle,
                                                    _radiusItemFn: this._radiusItemFn,
                                                    id: 'payType',
                                                    icon: { companyId, orderType, navigation: this.props.navigation }
                                                }} />

                                                <View style={orderBaseStyle.fklxBox}>
                                                    {
                                                        payType && this.payTypeArr.map((item, index) => {
                                                            return <View key={index} style={orderBaseStyle.showOrderTipBox}>
                                                                { //尾款截止日期
                                                                    item.name === 'prepayAmtBalanceDate' ? <FormItem styleObj={{ size: 'small', valueStyle: { width: 100 * scale, textAlign: 'center' } }} rightIconStyle={{ marginLeft: 5 * scale }} type={'select'} label={item.title} value={prepayAmtBalanceDate} placeHolder={'请选择时间'} handleCallBack={() => { this.DatePicker.show(); }} required /> : <FormItem
                                                                        onBlurFn={() => { this._blurWriteCallBack(item.name) }}
                                                                        key={timeStamp + index} keyboardType={'numeric'}
                                                                        handleCallBack={(text) => { this._writeCallBack({ name: item.name, value: text }) }}
                                                                        labelStyle={orderBaseStyle.labelStyle} required={true} sizeType={'small'}
                                                                        placeHolder={'请输入'} label={item.title} value={item.value}
                                                                        rightText={item.text} rightTextStyle={{ fontSize: 12 * scale, color: '#333' }}
                                                                        inputStyle={{ textAlign: 'center' }}
                                                                        type={'input'}
                                                                    />
                                                                }
                                                            </View>
                                                        })
                                                    }
                                                    {this._sxzq()}
                                                    {this._zjcbSx()}
                                                </View>
                                                {trustShow ? <View style={orderBaseStyle.goodsZhi}><Text style={orderBaseStyle.address}>授信可用余额: ￥{CURRENCY.format(limitAmount)}元   <Text style={orderBaseStyle.address}>有效期至: {creditEndDate || ''}</Text>   <Text style={orderBaseStyle.address}>账期:{accountDay || 0}天</Text>  <Text onPress={() => { this.props.navigation.navigate('BillPage', { companyId, companyName, corpType: orderType == 'P' ? 1 : 0 }) }} style={[orderBaseStyle.billDetail]}>[查看明细]</Text></Text></View> : null}
                                                <RadiusGroupCpt data={{
                                                    title: this.PageText.payMethodTitle,
                                                    required: true,
                                                    listData: this.payMethodData,
                                                    selectedKey: payStyle,
                                                    textStyleBox: orderBaseStyle.textStyle,
                                                    _radiusItemFn: this._radiusItemFn,
                                                    id: 'payStyle'
                                                }} />
                                                {this._zjcbPj()}
                                            </View>

                                        )
                                }

                                {/* 运输信息 */}
                                {
                                    tCode == 'C' ? <AdressCBlock data={{
                                        navigation: this.props.navigation,
                                        initData: {
                                            deliveryDataBuy: this.deliveryDataBuy,
                                            deliveryDataSell: this.deliveryDataSell,
                                            transportTypeData: this.transportTypeData,
                                            lossData: this.lossData,
                                            lostRateData: this.lostRateData,
                                            orderFlag: this.orderFlag,
                                            goodsData: orderItemList || [],
                                        },
                                        editData: {
                                            buyData: this.sendBuyData.orderInfo || {},
                                            sellData: this.sendData.orderInfo || {}
                                        },
                                        addressBack: this._modalCallback
                                    }} /> : (
                                            <View style={[orderBaseStyle.box, orderBaseStyle.boxBottom]}>
                                                <TitleCpt
                                                    data={{
                                                        title: '运输信息',
                                                    }} />
                                                {(tCode == 'E' || tCode == 'QH') && this.orderFlag.type != "edit" && !deliveryTypeIsX ? (<View style={orderBaseStyle.radioBox}>
                                                    <Text style={orderBaseStyle.radioTitle}>交货方式</Text>
                                                    <Text style={orderBaseStyle.activeFonts}>{this._getDeliveryName(deliveryType, this.deliveryDataOld)}</Text>
                                                    {orderType == 'P' && deliveryType == 'Q' ? <TouchableOpacity style={{ paddingLeft: 5 * scale }} onPress={this._infoP}><Image style={{ width: 15 * scale, height: 15 * scale }} source={require('../../../imgs/global/query.png')} /></TouchableOpacity> : null}
                                                    {orderType == 'S' && deliveryType == 'P' ? <TouchableOpacity style={{ paddingLeft: 5 * scale }} onPress={this._infoS}><Image style={{ width: 15 * scale, height: 15 * scale }} source={require('../../../imgs/global/query.png')} /></TouchableOpacity> : null}
                                                </View>) : (
                                                        <RadiusGroupCpt data={{
                                                            title: '交货方式', required: true, listData: orderType == 'S' ? this.deliveryData : this.deliveryData.filter(item => item.dictKey != 'Q'),
                                                            selectedKey: deliveryType,
                                                            textStyleBox: orderBaseStyle.textStyle,
                                                            _radiusItemFn: this._radiusItemFn,
                                                            id: 'deliveryType',
                                                            orderType
                                                        }} />
                                                    )}

                                                {this._addressView()}
                                            </View>
                                        )
                                }

                                {/* 交货计划 */}
                                {
                                    tCode != 'QH' ? (<DeliveryBlock data={{ editData: orderDeliveryPlanList || null, user, planDataCall: this._planDataCall, resultQuantity: this._amount(), isLimit }} />) : null
                                }
                                {/* 费用 */}
                                {
                                    tCode != 'QH' ? (<FeeBlock data={{
                                        navigation: this.props.navigation, currency, feeCallback: this._feeCallback, feeEdit: orderFeeList, feeParams: orderInfo, isTransport: this._isTransport()
                                    }} />) : null
                                }
                                {
                                    tCode == 'QH' ? (remark ? <RemarkBlock data={{ title: '合同备注', placeholder: (tCode == 'QH') ? '' : '填写合同备注…', _writeTextFn: this._writeTextFn, id: 'remark', edit: remark, isEdit: (tCode == 'QH') ? '0' : '1' }} /> : null) : null
                                }
                                {
                                    tCode == 'E' ? (remark ? <RemarkBlock data={{ title: '合同备注', placeholder: '填写合同备注…', _writeTextFn: this._writeTextFn, id: 'remark', edit: remark, isEdit: '0' }} /> : null) : null
                                }
                                {
                                    tCode != 'E' && tCode != 'QH' ? <RemarkBlock data={{ title: '合同备注', placeholder: '填写合同备注…', _writeTextFn: this._writeTextFn, id: 'remark', edit: remark }} /> : null
                                }
                                <RemarkBlock data={{ title: '送审备注', placeholder: '填写送审备注…', _writeTextFn: this._writeTextFn, id: 'auditRemark', edit: auditRemark }} />

                            </View>) : null
                        }
                    </ScrollView>
                </View>




                {/* 老版本 暂时不用 */}
                {/* {
                    this.batch ? (<View style={orderBaseStyle.btnBox}>
                        <Button type={'outline'} width={136} height={34} text={"确认"} onPress={this._okFn} />
                    </View>) : (
                            <View style={orderBaseStyle.btnBox}>
                                <Button type={'outline'} width={136} height={34} text={"保存"} onPress={this._saveFn} />
                                <View style={orderBaseStyle.btnBoxNext}><Button text={(tCode == 'C' || tCode == 'QH' || tCode == 'A') ? "提交" : "下一步"} width={136} height={34} onPress={() => { this._nextFn() }} /></View>
                            </View>
                        )
                } */}

                <Common type="modal" demoData={(
                    <Common type="listRadio" selectIndex={lostRateIndex} title={'途损率'} listData={this.lostRateData || []} selectCallBack={this._lostRateCallBack} />
                )} isVisible={lostRateVisible} closeCallballFn={() => { this._closeModal('lostRateVisible') }} />
                <Common type="modal" demoData={(
                    <Common type="listRadio" selectIndex={branchIndex} title={'请选择部门'} listData={this.branchData || []} selectCallBack={this._branchCallBack} />
                )} isVisible={branchVisible} closeCallballFn={() => { this._closeModal('branchVisible') }} />
            </KeyboardAvoidingView>


            <BouncedCpt isVisible={isVisible} data={{
                closeFn: () => { this._hideDetials(false) },
                renderBody: <BodyCpt data={{ orderFlag: this.orderFlag, priceData: this.showPrice }} closeFn={() => { this._hideDetials(false) }} />
            }} />

            <BottomCpt data={{
                priceData: {
                    data: this.showPrice,
                    callback: () => { this._showPriceFn(this._changeSend()); this._hideDetials(true) },
                    isProfit: tCode == 'C' ? true : false, // 是否有毛利的标示
                    isC: true //是否是闭口
                    //totalGrossProfitAmtC: this.showPrice.orderPriceInfo.grossProfitAmt, // 底部总毛利
                },
                btnData: this.batch ? [{ text: '确认', callback: this._okFn }] : [
                    { text: '保存', callback: this._saveFn },
                    { text: (tCode == 'C' || tCode == 'QH' || tCode == 'A') ? "提交" : "下一步", callback: this._nextFn },
                ]
            }} />

            <DatePicker
                HH={false}
                mm={false}
                ss={false}
                startYear={2000}
                endYear={2200}
                onPickerConfirm={(value) => {
                    this.sendData.orderInfo.prepayAmtBalanceDate = OrderCreateMethods._endPayTime(value);
                    this.setState({ ls: true });
                }}
                onPickerCancel={() => {
                    console.log('cancel');
                }}
                ref={ref => this.DatePicker = ref} />

            {
                status != 'data' ? (<View style={orderBaseStyle.statusStyle}><PageStatusIndex status={status} /></View>) : null
            }
        </View >)
    }


    /* 清空数据 */
    _claerData = () => {
        let saleIsUnite = this.sendData.orderInfo.isUnite;
        let buyIsUnite = this.sendBuyData.orderInfo.isUnite;


        // 清空
        this.sendData = {
            orderInfo: Object.assign({}, this.default),
            orderDeliveryPlanList: [{ planId: null, deliveryBeginDate: null, deliveryEndDate: null, quantity: null }],
            orderItemList: [],
            orderFeeList: []
        }
        this.sendBuyData = {
            orderInfo: Object.assign({}, this.default),
            orderDeliveryPlanList: [{ planId: null, deliveryBeginDate: null, deliveryEndDate: null, quantity: null }],
            orderItemList: [],
            orderFeeList: []
        }
        //付款类型特殊处理
        this.payTypeArr && this.payTypeArr.map(item => {
            item.value = '';
            return item;
        })
        this.payTypeArr = [];

        //业务类型不清
        this.sendData.orderInfo.isUnite = saleIsUnite;
        this.sendBuyData.orderInfo.isUnite = buyIsUnite;

        this.setState({ ls: true })
        console.log('清空数据', this.sendData, this.sendBuyData)
    };
}